<?php

namespace app\index\model;

use think\Model;

class Classification extends Model {
    /**
     * @return Classification[]|\think\Collection
     * ljj
     * 返回职位类型
     */
    public function getClass()
    {
        return $this
            ->where('is_delete','=','0')
            ->field('class')
            ->orderRand()
            ->limit(8)
            ->select();
    }

    /**
     * 添加职位类型
     * ywh开发
     * @param $class
     * @return bool
     */
    public function upOff($class){
        return $this->save($class);
    }

    /**
     * 放回相应分类的职位信息
     * @copyright hyw
     * @param $class
     * @return Classification[]|\think\Collection
     */
    public function getChoseAttr($class) {
        return $this
            ->alias('cls')
            ->where('class','=',$class)
            ->join(['official' => 'o'],'o.official_id = cls.official_id')
            ->where('o.is_delete','=',0)
            ->join(['company' => 'com'],'com.company_id = o.company_id')
            ->where('com.is_delete','=',0)
            ->join(['cotype' => 'cot'],'cot.company_id = o.company_id')
            ->where('cot.is_delete','=',0)
            ->field(['o.official_id','official','company_area','job_money','education','wordweek',])
            ->field(['company_welfare','company_logo','company_name','type'])
            ->order('hot','desc')
            ->select();
    }

}